class MyThread extends Thread{
    @Override
    public void run(){
        while (true){
            System.out.println("线程1");
            try {
                sleep(100);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }
    }
}
public class Demo01 {
    public static void main(String[] args) {
        MyThread t=new MyThread();
        //start 会创建新的线程
        t.start();
        //run不会创建新的线程，run是在main线程中执行的
//        t.run();

        while (true){
            System.out.println("main方法");
            try {
                Thread.sleep(100);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }
    }
}
